package com.linkage.seapeak.activity.message;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.linkage.jz.bankruptcy.BankruptcyApp;
import com.linkage.jz.bankruptcy.R;
import com.linkage.jz.bankruptcy.activity.Project.ManagerListActivity;
import com.linkage.jz.bankruptcy.activity.Project.ProDetailActivity;
import com.linkage.jz.bankruptcy.activity.Project.ProTaskDetailActivity;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.ApplyChangeToMeActivity;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.ApplyChangeZQUserBaseInfoActivity;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.DetailOper.ApplyAddProxyUserActivity;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.DetailOper.ApplyChangerLegalRepActivity;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.DetailOper.ApplyChangerLegalUserNameActivity;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.DetailOper.ApplyChangerLegalUserName_ZQActivity;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.DetailOper.ApplyChangerZQUserNameActivity;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.DetailOper.ApplyEditProxyUserActivity;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.DetailOper.ApplyEditProxyUser_ZQActivity;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.DetailOper.ShowZQApplyActivity;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.DetailOper.ShowZQReviewActivity;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.ZQUserDetailActivity;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.ZQUserShowDetailActivity;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.ZQUserShowDetail_ZQRActivity;
import com.linkage.jz.bankruptcy.activity.Project.ZQUser.ZQUserZQDetailActivity;
import com.linkage.jz.bankruptcy.activity.Vote.ProVoteVoteDetailActivity;
import com.linkage.jz.bankruptcy.bean.ApplyChangerZQUserNameBean;
import com.linkage.jz.bankruptcy.bean.LoginInfo;
import com.linkage.jz.bankruptcy.bean.MyProInfo;
import com.linkage.jz.bankruptcy.bean.MyProInfoAuth;
import com.linkage.jz.bankruptcy.bean.Vote.ProVote;
import com.linkage.jz.bankruptcy.bean.ZQApplyDraft;
import com.linkage.jz.bankruptcy.bean.ZQBaseInfo;
import com.linkage.jz.bankruptcy.bean.ZQBaseProjectCrDecInfo;
import com.linkage.jz.bankruptcy.bean.ZQShowCrDecInfo;
import com.linkage.jz.bankruptcy.bean.ZQUserDetailBaseInfo;
import com.linkage.jz.bankruptcy.event.RefreshEvent;
import com.linkage.jz.bankruptcy.net.BaseSubscriber;
import com.linkage.jz.bankruptcy.net.Network;
import com.linkage.jz.bankruptcy.utils.BundleUtils;
import com.linkage.seapeak.activity.chat.SearchProjectActivity;
import com.linkage.seapeak.activity.project.CreditorReviewDetailActivity;
import com.linkage.seapeak.activity.project.DissentActionActivity;
import com.linkage.seapeak.activity.project.DissentShowActivity;
import com.linkage.seapeak.activity.project.SearchDeclarationInfoActivity;
import com.linkage.seapeak.activity.user.PermissionSettingActivity;
import com.linkage.seapeak.base.BaseActivity;
import com.linkage.seapeak.pojo.TempProject;
import com.linkage.seapeak.utils.ToastUtil;

import org.greenrobot.eventbus.EventBus;

import rx.Subscription;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * 获取消息通知,消息推送和操作记录的toPage
 * 然后跳转到新的页面中去
 */
public class GoToPageLoadingActivity extends BaseActivity {

    Subscription subscription;

    /**
     * Id	id	String	是	操作记录/消息的id
     * Id的类型	type	Int	是	0: 消息,1:操作记录,2:推送消息
     * @param context
     * @param id
     * @param type
     */
    public static void start(Activity context, String id, int type) {
        Intent intent = new Intent(context, GoToPageLoadingActivity.class);
        intent.putExtra("id", id);
        intent.putExtra("type", type);
        context.startActivity(intent);
        context.overridePendingTransition(R.anim.fade_in, 0);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_dialog);

        String id = getIntent().getStringExtra("id");
        int type = getIntent().getIntExtra("type", -1);
        String dataid = getIntent().getStringExtra("dataid");
        View main_bg = findViewById(R.id.main_bg);
        if (type == -1) {
            showToast("暂不支持跳转类型");
            finish();
            overridePendingTransition(0, R.anim.fade_out);
        } else if (type == 2) {
            main_bg.setBackgroundColor(0xffffffff);
        } else {
            main_bg.setBackgroundColor(0xcc333333);
        }


        subscription = Network.getAPIService()
                .getToPage(getUserToken(), id, type)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscriber<JsonObject>() {
                    @Override
                    public void onNext(JsonObject json) {
                        overridePendingTransition(0, R.anim.fade_out);
                        int code = json.get("code").getAsInt();
                        if (code != 0) {
                            super.onNext(json);
                            return;
                        }
                        JsonObject data = json.getAsJsonObject("data");
                        if (data.has("toPage")) {
                            int toPage = data.get("toPage").getAsInt();
                            JsonObject pageData = data.getAsJsonObject("pageData");
                            turnToPage(toPage, pageData);
                        } else
                            onError(null);
                    }

                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {
                        e.printStackTrace();
                        showToast("数据错误");
                        finish();
                        overridePendingTransition(0, R.anim.fade_out);
                    }
                });
    }

    @Override
    public void onBackPressed() {
        if (subscription != null && !subscription.isUnsubscribed())
            subscription.unsubscribe();
        finish();
        overridePendingTransition(0, R.anim.fade_out);
    }

    /**
     * toPage: 用于区分跳转到哪个页面
     * pageData:跳转到该页面需要携带的数据
     * 这两个字段的取值如下:
     * 概要:
     *             大概分为:
     *                 纯页面跳转
     * 查看历史数据
     *         toPage(1开头债权人端,2:开头管理人端,300x开头是消息相关):
     *         债权人端:
     *             0: 只展示,无逻辑
     *             1: 债权人提交的身份信息页面,无操作只查看
     *                 pageData:creditorLog 债权人数据
     *             2: 修改基础信息页面,无操作
     *                 pageData:creditorLog
     *             3: 身份验证已通过页面; 债权（已申报）-我的基础信息页面
     *                 pageData:creditorId
     *             4: 审核不通过身份验证; 债权（基础信息验证不通过）
     *                 pageData:creditorId
     *             5: 申请变更债权人名称页面,只罗列字段展示
     *                     pageData:changeLog
     *             6: 申请新增代理人页面,只罗列字段
     *                     pageData:changeLog
     *             7: 申请变更代理人页面,只罗列字段
     *                     pageData:changeLog
     *             8: 更改法定代表人页面,只罗列字段
     *                 pageData:changeLog
     *             9: 申请变更为法定代表人操作,只罗列字段
     *                  pageData:changeLog
     *             10: 申请变更为本人操作,只罗列字段
     *                 pageData:changeLog
     *             11: 变更债权人页面,只罗列字段
     *                 pageData:creditorLog
     *             12: 管理人同意/拒绝债权人名称变更,跳转到:身份验证已通过页面; 债权（已申报）-我的基础信息页面
     *                  pageData:creditorId
     *             13: 管理人同意/拒绝更改法定代表人,跳转到:身份验证已通过页面; 债权（已申报）-我的基础信息页面
     *                  pageData:creditorId
     *             14: 管理人同意/拒绝变更代理人,跳转到:身份验证已通过页面; 债权（已申报）-我的基础信息页面
     *                 pageData:creditorId
     *             15: 管理人同意/拒绝新增代理人,跳转到:身份验证已通过页面; 债权（已申报）-我的基础信息页面
     *                  pageData:creditorId
     *             16: 管理人同意/拒绝变更为本人操作,跳转到:身份验证已通过页面; 债权（已申报）-我的基础信息页面
     *                 pageData:creditorId
     *             17: 管理人同意/拒绝变更为法定代表人操作,跳转到:身份验证已通过页面; 债权（已申报）-我的基础信息页面
     *                    pageData:creditorId
     *             18: 债权人编辑身份信息.查看历史数据
     *                    pageData:creditorLog
     *             19: 债权人查看提出异议.查看历史记录
     *                    pageData:decRevObjeLog
     *             20: 债权人查看异议回复.查看历史记录
     *                    pageData:decRevObjeLog
     *             21: 债权人查看审查意见.跳转到审查页面
     *                    pageData:projectId,creditorId,crReviewId,creditorRightsId
     *             22: 债权人查看审查意见.查看历史记录
     *                    pageData:crDecRev,projectCrDec,creditorInfo
     *             23: 债权人查看申报信息.查看历史数据
     *                   pageData:projectCrDec
     *
     *         管理人端:
     *             201: 跳转到身份待验证页面-做身份验证
     *                 pageData:creditorId
     *             202: 债权人提交的身份信息页面-历史数据
     *                 pageData:creditorLog
     *             203: 修改基础信息不审核-历史数据
     *                 pageData:creditorLog
     *             204: 身份信息审核通过-跳转至债权人管理-基础信息-已确认债权
     *                 pageData:creditorId
     *             205: 身份信息审核不通过-跳转至债权人管理-已确认-基础信息-已通知/已拒绝
     *                 pageData:creditorId
     *             206: 申请变更债权人名称待审核-跳转至审核页面去审核
     *                 pageData:changeId
     *             207: 申请变更债权人名称已审核-查看历史数据
     *                 pageData:changeLog
     *             208: 申请新增代理人待审核-跳转至审核页面
     *                 pageData:changeId
     *             209: 申请新增代理人已审核-查看历史数据
     *                 pageData:changeLog
     *             210: 申请变更代理人待审核-跳转到审核页面
     *                 pageData:changeId
     *             211: 申请变更代理人已审核-历史数据
     *                 pageData:changeLog
     *             212: 更改法定代表人待审核-跳转到审核页面
     *                 pageData:changeId
     *             213: 更改法定代表人已审核-历史数据
     *                 pageData:changeLog
     *             214: 变更为法定代表人操作待审核-跳转到审核页面
     *                 pageData:changeId
     *             215: 变更为法定代表人操作已审核-历史数据
     *                 pageData:changeLog
     *             216: 变更为本人操作待审核-跳转到审核页面
     *                 pageData:changeId
     *             217: 变更为本人操作已审核-历史数据
     *                 pageData:changeLog
     *             218: 变更债权人-历史数据
     *                 pageData:creditorLog
     *             219: 管理人同意/拒绝债权人名称变更-跳转到: 债权人管理-基础信息-已确认债权页面
     *                 pageData:creditorId
     *             220:  管理人同意/拒绝更改法定代表人-跳转到: 债权人管理-基础信息-已确认债权页面
     *                 pageData:creditorId
     *             221:  管理人同意/拒绝变更代理人-跳转到: 债权人管理-基础信息-已确认债权页面
     *                 pageData:creditorId
     *             222:  管理人同意/拒绝新增代理人-跳转到: 债权人管理-基础信息-已确认债权页面
     *                 pageData:creditorId
     *             223:  管理人同意/拒绝变更为本人操作-跳转到: 债权人管理-基础信息-已确认债权页面
     *                 pageData:creditorId
     *              224: 管理人同意/拒绝变更为法定代表人操作-跳转到: 债权人管理-基础信息-已确认债权页面
     *                 pageData:creditorId
     *             225:  跳转到身份待验证页面-做身份验证
     *                 pageData:creditorId
     *             226: 债权人提交的身份信息页面-历史数据
     *                 pageData:creditorLog
     *             227: 管理人查看提出异议.查看记录（未回复有回复按钮）
     *                    pageData:decRevObjeLog
     *             228: 管理人查看异议回复.查看历史记录
     *                    pageData:decRevObjeLog
     *             229: 管理人查看审查意见.跳转到审查页面
     *                    pageData:projectId,creditorId,crReviewId,creditorRightsId
     *             230: 管理人查看审查意见.查看历史记录
     *                    pageData:crDecRev,projectCrDec,creditorInfo
     *             231: 管理人查看申报信息.跳转到债权申报信息页面
     *                   pageData:projectId,creditorId,creditorRightsId
     *             232: 管理人查看申报信息.查看历史数据
     *                   pageData:projectCrDec
     *
     * // 消息新加的
     * 3001 : 跳转到我的项目页面(邀请债权人-债权人端)
     *             3002 : 债权人进程中页面(债权人拒绝邀请-管理人端)
     *                 pageData:creditorId
     *             3003 : 债权页面->项目概况(我加入的-债权(未申报)页面) (身份验证已通过并且暂未申报-债权人端)
     *   pageData:projectId
     *             3004 : 债权人接收债权申报期限通知(跳转到债权信息页)
     *     pageData:projectId,creditorId
     * 3005 : 项目进度更新(跳转到项目进度信息页)
     *     pageData:nodeId
     * 3006 : 项目名称重复(不需要跳转)
     *     pageData:projectId,projectName
     * 3007 : 配置管理组成员权限(跳转到项目的管理组成员页面)
     *     pageData:projectId
     * 3008 : 创建任务或执行任务(跳转到对应任务详情页)
     *     pageData:taskId
     * 3009: 表决通知、表决通知（开启提前参会签到）、表决即将开始提醒、表决开始后提醒表决、表决事项撤销通知
     *     pageData:voteId 表决id
     * 3010: 表决退出参会通知
     *    pageData:voteId 表决id
     *               voteRule 表决规则类型
     * 3011: 表决开放修改通知
     *    pageData:voteId 表决id
     *               activeName=3 标签激活 固定值
     * 3012: 表决结果发布通知
     *     pageData:voteId 表决id
     *
     *     String creditorId = pageData.get("creditorId").getAsString();
     *         String projectId = pageData.get("projectId").getAsString();
     *         String crReviewId = pageData.get("crReviewId").getAsString();
     *         String creditorRightsId = pageData.get("creditorRightsId").getAsString();
     *         int voteRule = pageData.get("voteId").getAsInt();
     *         String voteId = pageData.get("voteId").getAsString();
     *         String taskId = pageData.get("taskId").getAsString();
     *
     */

    private void turnToPage(int toPage, JsonObject pageData) {
        overridePendingTransition(0, R.anim.fade_out);
        String creditorId = "";
        String projectId = "";
        String crReviewId = "";
        String creditorRightsId = "";
        int voteRule = 0;
        String voteId = "";
        String taskId = "";
        Intent intent = null;
        switch (toPage) {
            case 0:
                ToastUtil.getInstance(this).showShortToast("无展示信息");
                break;
            case 1: case 2:  case 202: case 203: case 18:
                ZQUserDetailBaseInfo info = new Gson().fromJson(pageData.getAsJsonObject("creditorInfo"),ZQUserDetailBaseInfo.class);
                ZQUserShowDetailActivity.start(GoToPageLoadingActivity.this,info);
                finish();
                break;

            case 218: case 11:
                ZQUserDetailBaseInfo info218 = new Gson().fromJson(pageData.getAsJsonObject("change"),ZQUserDetailBaseInfo.class);
                ZQUserShowDetail_ZQRActivity.start(GoToPageLoadingActivity.this,info218);
                finish();
                break;
            case 4:
                projectId = pageData.getAsJsonObject("projectInfo").get("id").getAsString();
                getProjectDetail(projectId, toPage);
                finish();
                break;

            case 5:
                ApplyChangerZQUserNameBean bean5 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
                bean5.setChange(bean5.getCreditorInfo());
                ApplyChangerZQUserNameActivity.start(GoToPageLoadingActivity.this, bean5, 1);
                finish();
                break;
//            case 18:
//                finish();
//                break;
            case 19:
                pageData = pageData.getAsJsonObject("decRevObjeLog");
                DissentShowActivity.start(GoToPageLoadingActivity.this, pageData.toString(), 0);
                finish();
                break;
            case 227:
                pageData = pageData.getAsJsonObject("decRevObjeLog");
                creditorId = pageData.get("creditorId").getAsString();
                projectId = pageData.get("bankruptcyProjectId").getAsString();
//               String crRevObjId = pageData.get("creditorRightReviewId").getAsString();
                DissentActionActivity.start(GoToPageLoadingActivity.this, projectId, creditorId, "");
                finish();
                return;

            case 20:
            case 228:
                pageData = pageData.getAsJsonObject("decRevObjeLog");
                DissentShowActivity.start(GoToPageLoadingActivity.this, pageData.toString(), 1);
                finish();
                return;

            case 3: case 12: case 13: case 14:
            case 15: case 16: case 17:
//                creditorRightsId = pageData.get("creditorRightsId").getAsString();
                creditorId = pageData.get("creditorId").getAsString();
                projectId = pageData.get("projectId").getAsString();
                intent = new Intent(GoToPageLoadingActivity.this, ZQUserZQDetailActivity.class);
                intent.putExtra("creditorId", creditorId);
//                if (creditorRightsId != null)
//                    intent.putExtra("creditorRightsId", creditorRightsId);
//                else
//                    intent.putExtra("creditorRightsId", "");
                intent.putExtra("page", "0");
                intent.putExtra("proid", projectId);
                startActivity(intent);
                finish();
                return;

            case 206:
                ApplyChangerZQUserNameBean bean = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
                ApplyChangerZQUserNameActivity.start(GoToPageLoadingActivity.this, bean, 0);
                finish();
                return;
            case 207:
                ApplyChangerZQUserNameBean beantmp = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);

                ApplyChangerZQUserNameActivity.start(GoToPageLoadingActivity.this, beantmp, 1);
                finish();
                return;

            case 208:
                ApplyChangerZQUserNameBean beantmp208 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
//
                ApplyAddProxyUserActivity.start(GoToPageLoadingActivity.this, beantmp208, 0);
                finish();
                return;
            case 209: case 6:
                ApplyChangerZQUserNameBean beantmp209 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
//
                ApplyAddProxyUserActivity.start(GoToPageLoadingActivity.this, beantmp209, 1);
                finish();
                return;

            case 210:
                ApplyChangerZQUserNameBean beantmp210 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
//
                ApplyEditProxyUserActivity.start(GoToPageLoadingActivity.this, beantmp210, 0);
                finish();
                return;
            case 211:
                ApplyChangerZQUserNameBean beantmp211 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
//
                ApplyEditProxyUserActivity.start(GoToPageLoadingActivity.this, beantmp211, 1);
                finish();
                return;

            case 7:
                ApplyChangerZQUserNameBean beantmp7 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
//
                ApplyEditProxyUser_ZQActivity.start(GoToPageLoadingActivity.this, beantmp7, 1);
                finish();
                return;

            case 212:
                ApplyChangerZQUserNameBean beantmp212 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
//
//                ApplyChangerLegalRepActivity.start(GoToPageLoadingActivity.this, beantmp212, 0);
                ApplyChangerLegalUserNameActivity.start(GoToPageLoadingActivity.this, beantmp212, 0);
                finish();
                return;
            case 213:
                ApplyChangerZQUserNameBean beantmp213 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
//
                ApplyChangerLegalUserNameActivity.start(GoToPageLoadingActivity.this, beantmp213, 1);
                finish();
                return;
            case 8:
                ApplyChangerZQUserNameBean beantmp8 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
//
                ApplyChangerLegalUserName_ZQActivity.start(GoToPageLoadingActivity.this, beantmp8, 1);
                finish();
                return;
            case 214:

                ApplyChangerZQUserNameBean beantmp214 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
//
//                if("变更为法定代表人操作".equalsIgnoreCase(beantmp214.getChange().getType().getText()))
//                {
                    ApplyChangerLegalRepActivity.start(GoToPageLoadingActivity.this, beantmp214, 0,true);
//                }else {
//                    ApplyChangerLegalUserNameActivity.start(GoToPageLoadingActivity.this, beantmp214, 0);
//                }
                finish();
                return;
            case 215: case 9:
                ApplyChangerZQUserNameBean beantmp215 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
                    ApplyChangerLegalRepActivity.start(GoToPageLoadingActivity.this, beantmp215, 1,true);
                finish();
                return;

            case 234:

                ApplyChangerZQUserNameBean beantmp234 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
//
//                if("变更为法定代表人操作".equalsIgnoreCase(beantmp214.getChange().getType().getText()))
//                {
                ApplyChangerLegalRepActivity.start(GoToPageLoadingActivity.this, beantmp234, 0,false);
//                }else {
//                    ApplyChangerLegalUserNameActivity.start(GoToPageLoadingActivity.this, beantmp214, 0);
//                }
                finish();
                return;
            case 235:
                ApplyChangerZQUserNameBean beantmp235 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
//
//                if("变更为法定代表人操作".equalsIgnoreCase(beantmp235.getChange().getType().getText()))
//                {
                    ApplyChangerLegalRepActivity.start(GoToPageLoadingActivity.this, beantmp235, 1,false);
//                }else {
//                    ApplyChangerLegalUserNameActivity.start(GoToPageLoadingActivity.this, beantmp235, 1);
//                }
                finish();
                return;

            case 24:
                ApplyChangerZQUserNameBean beantmp24 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
//
//                if("变更为法定代表人操作".equalsIgnoreCase(beantmp235.getChange().getType().getText()))
//                {
                ApplyChangerLegalRepActivity.start(GoToPageLoadingActivity.this, beantmp24, 1,false);
//                }else {
//                    ApplyChangerLegalUserNameActivity.start(GoToPageLoadingActivity.this, beantmp235, 1);
//                }
                finish();
                return;



            case 216:
                ApplyChangerZQUserNameBean beantmp216 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
//
                ApplyChangeToMeActivity.start(GoToPageLoadingActivity.this, beantmp216, 0);
                finish();
                return;
            case 217:
                ApplyChangerZQUserNameBean beantmp217 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
//
                ApplyChangeToMeActivity.start(GoToPageLoadingActivity.this, beantmp217, 1);
                finish();
                return;

            case 10:
                ApplyChangerZQUserNameBean beantmp10 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
//
                ApplyChangeToMeActivity.start(GoToPageLoadingActivity.this, beantmp10, 1);
                finish();
                return;

//            case 218:
//                ApplyChangerZQUserNameBean beantmp218 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
////
//                ApplyChangeZQUserBaseInfoActivity.start(GoToPageLoadingActivity.this, beantmp218, 0, 0);
//                finish();
//                return;
//            case 219:
//                ApplyChangerZQUserNameBean beantmp219 = new Gson().fromJson(pageData.toString(), ApplyChangerZQUserNameBean.class);
////
//                ApplyChangeZQUserBaseInfoActivity.start(GoToPageLoadingActivity.this, beantmp219, 0,1);
//
//                return;

            case 232: case 23:

                ZQShowCrDecInfo beantmp232= new Gson().fromJson(pageData.toString(), ZQShowCrDecInfo.class);
                ShowZQApplyActivity.start(GoToPageLoadingActivity.this,beantmp232);
                finish();
                return;

            case 230: case 22:

                ZQShowCrDecInfo beantmp230= new Gson().fromJson(pageData.toString(), ZQShowCrDecInfo.class);
                ShowZQReviewActivity.start(GoToPageLoadingActivity.this,beantmp230);
                finish();
                return;

            case 201: case 204: case 205: case 219:
            case 220: case 221: case 222: case 223:
            case 224: case 225: case 226: case 3002:
                creditorId = pageData.get("creditorId").getAsString();
                projectId = pageData.get("projectId").getAsString();
                intent = new Intent(GoToPageLoadingActivity.this, ZQUserDetailActivity.class);
                intent.putExtra("creditorId", creditorId);
                intent.putExtra("proid", projectId);
                startActivity(intent);
                finish();
                return;

            case 21:

                creditorId = pageData.get("creditorId").getAsString();
                projectId = pageData.get("projectId").getAsString();
                crReviewId = pageData.get("crReviewId").getAsString();
                creditorRightsId = pageData.get("creditorRightsId").getAsString();


                String  bigType1 = pageData.get("identityBigTypes").getAsJsonObject().get("value").getAsString();
                int  review1 = 0;
                try {
                    review1 =  pageData.get("reviewStatus").getAsJsonObject().get("value").getAsInt();
                }catch (Exception exp)
                {
                    exp.printStackTrace();
                }

                int  declareStatus1 = 0;
                try {
                    declareStatus1 = pageData.get("declareStatus").getAsJsonObject().get("value").getAsInt();
                }catch (Exception exp)
                {
                    exp.printStackTrace();
                }
                boolean isReplenishOrReviewPage1 = false;
                if(declareStatus1 == 0)
                {
                    isReplenishOrReviewPage1 = true;
                }

                jumpLookDetailPage(bigType1,projectId,crReviewId,creditorRightsId,review1,isReplenishOrReviewPage1,false);
                finish();
                break;

            case 229:

                creditorId = pageData.get("creditorId").getAsString();
                projectId = pageData.get("projectId").getAsString();
                crReviewId = pageData.get("crReviewId").getAsString();
                creditorRightsId = pageData.get("creditorRightsId").getAsString();


                String  bigType = pageData.get("identityBigTypes").getAsJsonObject().get("value").getAsString();
                int  review = pageData.get("reviewStatus").getAsJsonObject().get("value").getAsInt();
                int  declareStatus = pageData.get("declareStatus").getAsJsonObject().get("value").getAsInt();
                boolean isReplenishOrReviewPage = false;
                if(declareStatus == 0)
                {
                    isReplenishOrReviewPage = true;
                }

                jumpLookDetailPage(bigType,projectId,crReviewId,creditorRightsId,review,isReplenishOrReviewPage,true);
                finish();
                break;
            case 231: case 233:
                creditorId = pageData.get("creditorId").getAsString();
                projectId = pageData.get("projectId").getAsString();
                intent = new Intent(GoToPageLoadingActivity.this, ZQUserDetailActivity.class);
                intent.putExtra("creditorId", creditorId);
                intent.putExtra("proid", projectId);
                intent.putExtra("page", 1);
                startActivity(intent);

                finish();
                return;
            case 3001:
                RefreshEvent event = new RefreshEvent();
                event.setType(RefreshEvent.TYPE_MY_PRO);
                EventBus.getDefault().post(event);
                finish();
                break;
//            case 3002:
//                break;
           case 3003: case 3004: case 3005: case 3013:
                projectId = pageData.get("projectId").getAsString();
                getProjectDetail(projectId, toPage);
                finish();
                return;

            case 3007:
//              ManagerListActivity
                projectId = pageData.get("projectId").getAsString();
                MyProInfo mInfo = new MyProInfo();
                mInfo.setId(projectId);
                ManagerListActivity.start(GoToPageLoadingActivity.this, mInfo);
                finish();
                return;
//            表决相关
            case 3008:
                taskId = pageData.get("id").getAsString();
                intent = new Intent(GoToPageLoadingActivity.this, ProTaskDetailActivity.class);
                intent.putExtra(ProTaskDetailActivity.KEY_ID, taskId);
                startActivity(intent);
                finish();
                return;

            case 3009: case 3010:
            case 3011: case 3012:

                ProVote item = new ProVote();
               String vId = pageData.get("voteId").getAsString();
                item.setId(vId);
                BundleUtils.saveProVote(item);
                 intent = new Intent(GoToPageLoadingActivity.this, ProVoteVoteDetailActivity.class);
                startActivity(intent);
                finish();
                return;
        }
        finish();

    }

    /**
     * 通过iD获取项目 3007
     * @param projectId
     */
    private void getProjectDetail(String projectId, int toPage) {
        Network.getAPIService()
                .getDetailInfo(getUserToken(), projectId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseSubscriber<JsonObject>() {
                    @Override
                    public void onNext(JsonObject json) {
                        int code = json.get("code").getAsInt();
                        if (code != 0) {
                            return;
                        } else {
                            try {
                                TempProject tempProject = new Gson().fromJson(json.getAsJsonObject("data")
                                        .toString(), TempProject.class);
                                //少了用户身份
                                MyProInfoAuth auth =  new Gson().fromJson(json.getAsJsonObject("data")
                                        .getAsJsonObject("auth").toString(), MyProInfoAuth.class);
                                 MyProInfo mInfo = new MyProInfo();
                                mInfo = tempProject.turnData(mInfo);
                                mInfo.setAuth(auth);
                                if (toPage == 3003|| toPage == 3004 || toPage == 3005||toPage == 3013) {
                                    Intent intent = new Intent(GoToPageLoadingActivity.this, ProDetailActivity.class);
                                    intent.putExtra("info", new Gson().toJson(mInfo));
                                    startActivity(intent);
                                } else if (toPage == 3007) {
//                                    PermissionSettingActivity.start(GoToPageLoadingActivity.this, mInfo);
                                } else if (toPage == 4) {
                                    Intent intent = new Intent(GoToPageLoadingActivity.this, ProDetailActivity.class);
                                    intent.putExtra("info", new Gson().toJson(mInfo));
                                    startActivity(intent);
                                }
                                finish();
                            } catch (Exception ex) {
                                ex.printStackTrace();
                            }
                        }
                    }

                    @Override
                    public void onCompleted() {
                        super.onCompleted();
                    }

                    @Override
                    public void onError(Throwable e) {
                        super.onError(e);
                    }
                });

    }


    private void jumpLookDetailPage(String bigType, String  mProid,String crReviewId ,String creditorRightsId,int review, boolean isReplenishOrReviewPage,boolean isGM) {
        Intent intent = new Intent(GoToPageLoadingActivity.this, CreditorReviewDetailActivity.class);
        intent.putExtra(CreditorReviewDetailActivity.INTENT_IS_MANAGE_TYPE, isGM);//todo 需要标识判断
        intent.putExtra(CreditorReviewDetailActivity.INTENT_IS_TAX_MODE, "2".equalsIgnoreCase(bigType));//true：税务，false： //非税务
        intent.putExtra(CreditorReviewDetailActivity.INTENT_IS_REPLENISH_REVIEW, isReplenishOrReviewPage);//true:补充 类型
        intent.putExtra(CreditorReviewDetailActivity.INTENT_ID_PROJECT, mProid);
//        String crReviewId = proZQUserZQInfo.getCrReviewId();
//        if ("".equalsIgnoreCase(crReviewId)) {
//            if (proZQUserZQInfo.getProjectCrDec().getPreVersion() != null) {
//                crReviewId = proZQUserZQInfo.getProjectCrDec().getPreVersion().getReview().getId();
//            }
//        }
        intent.putExtra(CreditorReviewDetailActivity.INTENT_ID_REVIEW, crReviewId);
        intent.putExtra(CreditorReviewDetailActivity.INTENT_ID_CREDITOR_RIGHTS, creditorRightsId);
//        int review = 0;
        intent.putExtra(CreditorReviewDetailActivity.INTENT_REVIEW_STATUS, review);//todo 获取reviewStatus//1.重新生成
        startActivity(intent);
    }

}
